<style scoped src="./index.scss" lang="scss" rel="stylesheet/scss"></style>
<template src="./index.html"></template>

<script>
export default {
  data() {
    return {
      load: false,
      form: {
        //   余额支付
        isOpenBalancePay: 0,
        //   货到付款
        isOpenCashOnDelivery: 0,
      },

      apiUrl: {
        getItem: "mall-site-portal/pay-other-config/getItem",
        update: "mall-site-portal/pay-other-config/saveOrUpdate",
      },
    };
  },
  methods: {
    init() {
      this.getSet();
    },
    async getSet() {
      this.load = true;
      let res = await this.$vFN.Http.post(
        {
          url: this.apiUrl.getItem,
        },
        window
      );

      console.log(res);
      if (res._ok) {
        const { isOpenBalancePay, isOpenCashOnDelivery } = res.data;

        this.form.isOpenBalancePay = isOpenBalancePay;
        this.form.isOpenCashOnDelivery = isOpenCashOnDelivery;
        this.load = false;
      }
    },

    async submit() {
      this.load = true;
      let res = await this.$vFN.Http.post(
        {
          url: this.apiUrl.update,
          data: {
            ...this.form,
          },
        },
        window
      );

      this.load = false;
      if (res._ok) {
        this.$vFN.Tools.messageSuccess(res.message);
        this.init();
      }
    },
  },
  mounted() {
    this.init();
  },
  activated() {},
};
</script>

